/**
 * Created by li on 2017/2/7.
 */
var Hero = Enemy.extend({
    //mySprite:null,
    //name:'',
    //hp:0,

    //level:1,
    exp:0,
    expArr:[],
    //nameText:null,
    //levelText:null,
    //expText:null,

    //hpText:null,
    //attackNumber:5,
    //defenseNumber:1,

    //per level ，four property is added
    power:20,
    health:20,
    brains:20,
    agile:20,
    //every hero's Grow is constan
    //the range 1~3
    powerGrow:1,
    healthGrow:1,
    brainsGrow:1,
    agileGrow:1,
    //
    weapon:null,
    protectionSuit:null,
    shoe:null,

    ctor:function(tag){
        var sprite = new cc.Sprite(res.monster_png,cc.rect(tag.mySprite[0],tag.mySprite[1],tag.mySprite[2],tag.mySprite[3]));
        sprite.attr({
            x: size.width/9,
            y: size.height - size.height/2,
            //x: 100,
            scaleX:3,
            scaleY:3,
        });

        this.mySprite = sprite;
        this.type = tag.type;
        this.level = tag.level;
        this.exp = tag.exp;
        //this.expArr = tag.expArr;
        for(var i=1;i<100;i++){
            this.expArr[i] = i*i*i*10+10;
        }
        this.name = tag.name;
        this.hp = tag.hp;
        this.hpMax = tag.hpMax;
        this.attackNumber = tag.attackNumber;
        this.defenseNumber = tag.defenseNumber;

        this.power = tag.power;
        this.health = tag.health;
        this.brains = tag.brains;
        this.agile = tag.agile;
        this.powerGrow = tag.powerGrow;
        this.healthGrow = tag.healthGrow;
        this.brainsGrow = tag.brainsGrow;
        this.agileGrow = tag.agileGrow;

        this.weapon = tag.weapon;
        this.protectionSuit = tag.protectionSuit;
        this.shoe = tag.shoe;


    },
//    attack:function(enemy){

//    },
    addExp:function(exp){
        this.exp += exp;
        this.isLeavlUp();
    },
    isLeavlUp:function(){
        if(this.exp > this.expArr[this.level]){
            this.exp -= this.expArr[this.level];
            this.level++;
            this.levelText.initWithString('level:'+this.level);

            this.power += this.powerGrow;
            this.health += this.healthGrow;
            this.brains += this.brainsGrow;
            this.agile += this.agileGrow;

            this.hpMax  = this.health*5;
            this.defenseNumber = this.health;
            this.attackNumber = this.power*3;
            //brains
            this.critical = this.agile*0.004;
            this.dodge = this.agile*0.002;

            cc.audioEngine.playEffect(res.leaveUp_mp3,false);
            this.isLeavlUp();
        }
    },




});
